<template>
	<view class="container">
		<uni-section>
			<view class="example">
				<!-- 基础用法，不包含校验规则 -->
				<uni-forms ref="baseForm" :modelValue="baseFormData" label-width="150rpx">
					<uni-forms-item label="患者姓名" required>
						<uni-easyinput disabled="" v-model="baseFormData.xm" placeholder="请输入姓名" />
					</uni-forms-item>
					<uni-forms-item label="性别" required>
						<uni-easyinput disabled="" v-model="baseFormData.xb" placeholder="请输入性别" />
					</uni-forms-item>
					<uni-forms-item label="年龄" required>
						<uni-easyinput disabled="" v-model="baseFormData.nl" placeholder="请输入年龄" />
					</uni-forms-item>
					<uni-forms-item label="体位" >
						<uni-data-select  v-model="baseFormData.tw" :localdata="tw"
							placeholder="请选择体位" />
					</uni-forms-item>
					<uni-forms-item label="担架" >
						<uni-data-checkbox v-model="baseFormData.dj" :localdata="stretcher" />
					</uni-forms-item>
					<uni-forms-item label="说明" >
						<uni-easyinput type="textarea" v-model="baseFormData.bz" placeholder="请输入备注" />
					</uni-forms-item>
				</uni-forms>
			</view>
		</uni-section>
        <view class="fixedBottom">
			<button  @click="woundedSave()">申请</button>
			<button  @click="woundedList()">后送管理</button>
		</view>
	</view>
</template>

<script>
	import { dictionary,evacuation } from '../../api/huanzhe.js'
	import { toast } from '../../utils/utils.js'
	export default {
		data() {
			return {
				baseFormData:[],
				tw:[],
				stretcher:[
					{
						text:'需要',
						value:'需要'
					},
					{
						text:'不需要',
						value:'不需要'
					}
				],
				title:{
					xm:null,
					xb:null,
					nl:null
				}
			}
		},
		onLoad(option){
			var parameter=JSON.parse(option.data)
			this.baseFormData.xm=parameter.xm
			this.baseFormData.xb=parameter.xb
			this.baseFormData.nl=parameter.nl
			this.baseFormData.id=parameter.id
			this.queryTw()
		},
		methods: {
			// 查询体位
			queryTw(){
				dictionary('weiqin_tiwei').then(res=>{
					res.data.forEach((item,index)=>{
						var tw={
							value:item.dictValue,
							text:item.dictLabel
						}
						this.tw.push(tw)
					})
				})
			},
			// 保存
			woundedSave(){
				console.log(this.baseFormData);
				const addQuery={
					bz:this.baseFormData.bz,
					dj:this.baseFormData.dj,
					hzId:this.baseFormData.id,
					tw:this.baseFormData.tw
				}
				evacuation(addQuery).then(res=>{
					toast(res.msg)
				})
				uni.redirectTo({
					url:'/pages/casualtyList/index'
				})
			},
			// 后送记录
			woundedList(){
				uni.redirectTo({
					url:'/pages/evacuation/index'
				})
			}
		}
	}
</script>

<style lang="scss">
.container{
	margin: 30rpx;
}
.fixedBottom{
		height: 200rpx;
		background-color: #FFF;
		position: fixed;
		bottom: 0rpx;
		left: 0;
		right: 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
		z-index: 50;
		button{
			width: 300rpx;
			height: 88rpx;
			color: white;
			background-color: #23440d;
			border-radius: 20px;
			line-height: 88rpx;
			text-align: center;
		}
	}
</style>
